import Request from './reuqest'
import { BASE_URL, TIME_OUT } from './reuqest/config'
import LocalCache from '@/utils/cache'
export const service = new Request({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  interceptors: {
    requestInterceptor: (config) => {
      // 携带token的拦截
      const token = LocalCache.getCache('token')
      if (token) {
        config.headers.Authorization = `Bearer ${token}`
      }
      // console.log('service独有的请求拦截器')
      return config
    },
    requestInterceptorCatch: (err) => {
      return err
    },
    responseInterceptor: (config) => {
      // console.log('service独有的响应拦截器')
      return config
    },
    responseInterceptorCatch: (err) => {
      return err
    }
  }
})

// export const service2 = new Request({
//   baseURL: BASE_URL,
//   timeout: TIME_OUT
// })
